DAX (Data Analysis Expressions) relationship functions in Power BI allow users to manage and navigate relationships between tables. These functions are essential for creating complex data models and ensuring accurate calculations across related tables.
Syntax:
RELATEDTABLE(<table>)
Description:
Returns a table that contains rows related to the current row. This function is used to create a table of related rows based on the existing relationships in the data model.
Steps to Create the Calculated Column in Power BI Desktop
Ensure Relationship: Make sure there is a relationship between the Sales table and the Products table on the ProductID column. You can check this in the "Manage Relationships" dialog.
Open Power BI Desktop.
Load your data into the data model.
Go to the Data view by clicking on the table icon on the left pane.
Select the Products table.
Click on "New Column" in the Modeling tab.
Enter the DAX formula into the formula bar:
TotalSales = SUMX(RELATEDTABLE(Sales), Sales[SalesAmount])
Press Enter to create the calculated column.
Result
The Products table will now have an additional column called "TotalSales":
Comments
Post a Comment